[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

Object get keys and values method

Object get keys and values method

【JS幼幼班】Step.04 基本語法:變數

【JS幼幼班】Step.04 基本語法:變數

550. Game Play Analysis IV

550. Game Play Analysis IV






留言討論